<% layout('layout') -%>
<div class="page-header">
  <div class="page-title">
    <h2>系统用户管理</h2>
    <span>查看并维护招投标参与单位及管理员账户</span>
  </div>
</div>

<div class="table-wrapper">
  <table class="table">
    <thead>
      <tr>
        <th>ID</th>
        <th>用户名</th>
        <th>角色</th>
        <th>单位名称</th>
        <th>法人姓名</th>
        <th>联系电话</th>
        <th>注册时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <% users.forEach(u => { %>
        <tr>
          <td><%= u.id %></td>
          <td><strong><%= u.username %></strong></td>
          <td><span class="tag"><%= u.role %></span></td>
          <td><%= u.company_name || '—' %></td>
          <td><%= u.legal_person || '—' %></td>
          <td><%= u.phone || '—' %></td>
          <td><%= u.created_at %></td>
          <td>
            <form method="post" action="/admin/users/<%= u.id %>/role" class="form-inline form-slim">
              <select name="role">
                <option value="BIDDER" <%= u.role === 'BIDDER' ? 'selected' : '' %>>BIDDER</option>
                <option value="TENDERER" <%= u.role === 'TENDERER' ? 'selected' : '' %>>TENDERER</option>
                <option value="ADMIN" <%= u.role === 'ADMIN' ? 'selected' : '' %>>ADMIN</option>
              </select>
              <button type="submit" class="btn-outline">保存</button>
            </form>
          </td>
        </tr>
      <% }) %>
    </tbody>
  </table>
</div>


